<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>卡拉卡-在线选号平台</title>
		<link href="/css/style.css" rel="stylesheet" type="text/css" />
		<link href="/css/pagination.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="../js/jquery-1.7.min.js"></script>
		<script type="text/javascript" src="../js/jquery.pagination.js"></script>
		<script type="text/javascript" src="../js/jquery.cookie.js"></script>
		<script type="text/javascript" src="../js/logon.js"></script>
		<script language="javascript" type="text/javascript">
			var page = 0; //页面索引初始值
			var pageSize = 9; //每页显示条数初始化，修改显示条数，修改这里即可
			$(function () {
				//initTable(10); //Load事件，初始化表格数据，页面索引为0（第一页）
				//分页，PageCount是总条目数，这是必选参数，其它参数都是可选
				$("#Pagination").pagination($!{model.get("count")}, {
					callback:PageCallback, //PageCallback() 为翻页调用次函数。
					prev_text:"上一页",
					next_text:"下一页",
					items_per_page:pageSize,
					num_edge_entries:2, //两侧首尾分页条目数
					num_display_entries:3, //连续分页主体部分分页条目数
					current_page:page, //当前页索引
				});
				//翻页调用
				function PageCallback(page,jq) {
					initTable(page);
				}
				//请求数据
				function initTable(page) {
					$.ajax({
						type:"POST",
						dataType:"text",
						url:"/phone/page/$!{model.get("carrier")}", //提交到一般处理程序请求数据
						data:{page:page+1,pageSize:pageSize,keyword:'$!{model.get("keyword")}'}, //提交两个参数：pageIndex(页面索引)，pageSize(显示条数)
						success:function(data){
						//alert(data);
							$('#list-content').html('');
							$('#list-content').html(data);
						}
					});
				}
			});
			
			function search()
			{
				$("#searchForm").submit();
			}
			
			//选号码
			function pick(pid)
			{
				$.ajax({    
			        type:'post',
			        url:'/sale/check',
			        data:{pid:pid},
			        cache:false,
			        async:false,
			        dataType:'json',
			        success:function(data){
			        	if(data.msg =="true" ){
				            document.getElementById("pid").value=pid;
							$('#searchForm').attr("action", "/package");
							$("#searchForm").target="_self";
							$("#searchForm").submit();
				        }else{
				            alert("号码已被选，再选一个吧！");
				        }
			        },
			        error: function(){  //失败
				        alert('Error loading document');
				    }
			    });  
			}
			#if($!{model.get("error")}==1)
				alert("号码已被其他用户选了，返回再选一个吧!");
			#end
		</script>
	</head>

	<body>
		#include("header.html")
		<table width="100%" border="0" cellspacing="0" cellpadding="0" id="content">
			<tr><td valign="top" id="left">
			#include("menu_sale.html")
			</td>
			<td valign="top" id="right">
				<div id="order">
					<div class="title">
						<span>首页 &gt; $!{model.get("carrierName")} &gt; 选择号码</span>
					</div>
					<div class="step">
						<img src="/images/icon_big_buy.png" />
						您订购商品为：$!{model.get("carrierName")} &gt;
						<span class="green"></span>
					</div>
				</div>
				<div id="list">
					<div class="title">
						<span>选购号码</span>
						<div class="so">
							<form id="searchForm" name="searchForm" action="/phone/$!{model.get("carrier")}" method="post">
							<input type="text" name="keyword" class="sou_input" value="$!{model.get("keyword")}"/>
							<input type="hidden" name="carrier" value="$!{model.get("carrier")}"/>
							<input type="hidden" id="pid" name="pid"/>
							</form>
						</div>
					</div>
					<div class="data">
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tbody id="list-content">
							</tbody>
							<tr>
								<td colspan="3">
									<table width="100%" border="0" cellspacing="0" cellpadding="0">
										<tr>
											<td><div id="Pagination" class="pagination" style="margin:4px 0 0 0"></div></td>
											<td width="80">共$!{model.get("count")}条</td>
										</tr>
									</table>
								</td>
							</tr>
						</table>

					</div>
				</div>
				</td></tr></table>
		#include("footer.html")
	</body>
</html>
